<template>
  <div class="main_box" style="padding:10px">
    <div class="add_wrap">
      <el-form label-width="200px" v-if="dataInfo">
        <div class="tit">
          <h2>基础信息</h2>
          <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList">返回</el-button>
        </div>
        <el-row>
          <el-form-item label="功能键描述:">
            <span>{{ dataInfo.btnName }}</span>
          </el-form-item>
          <el-form-item label="功能键类型:">
            <span>{{ formatBtnType(dataInfo.btnType) }}</span>
          </el-form-item>
          <el-form-item label="创建人:">
            <span>{{ dataInfo.createUserName }}</span>
          </el-form-item>
          <el-form-item label="创建时间:">
            <span>{{ dataInfo.createDate }}</span>
          </el-form-item>
          <el-form-item label="修改人:">
            <span>{{ dataInfo.modifyUserName }}</span>
          </el-form-item>
          <el-form-item label="修改时间:">
            <span>{{ dataInfo.modifyDate }}</span>
          </el-form-item>
          <el-form-item label="备注:">
            <span>{{ dataInfo.remark }}</span>
          </el-form-item>
          <el-form-item label="功能键图片:">
            <div class="img-wrapper">
              <el-image title="点击可预览" v-if="dataInfo.btnImg" :src="dataInfo.btnImg"  alt="" :preview-src-list="[dataInfo.btnImg]" ></el-image>
            </div>
          </el-form-item>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import ServerBtnApi from '@/api/server/serverBtn';
export default {
  data() {
    return {
      dataInfo: {},
    };
  },
  computed: {
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      ServerBtnApi.getServerBtnInfo({ id: this.$route.query.id }).then(res => {
        this.dataInfo = res.data
      })
    },
    formatBtnType(cellValue) {
      if (cellValue === 1) {
        return '精选'
      } else if (cellValue === 2) {
        return '自由'
      } else if (cellValue === 3) {
        return '专属'
      }
    },
    returnList() {
      this.$store.dispatch('delView', this.$route);
      this.$router.push({ path: '/server/serverBtnManagement' })
    }
  },

}

</script>
<style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>

<style lang="scss" scoped>
.img-wrapper {
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: 3px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin: 0 auto;

  .el-image{
    width: 100%;
    &::v-deep img{
      height:auto
    }
  }
}
</style>
